package org.shoukaiseki.aqoeous.model;

import org.shoukaiseki.aqoeous.exception.ResultException;

import java.util.ArrayList;
import java.util.List;

/**
 * org.shoukaiseki.aqoeous.model.ResultModel
 * <br>
 *
 * @author 蒋カイセキ    Japan-Tokyo  19-2-11 下午3:55<br>
 * ブログ http://www.shoukaiseki.top/<br>
 * E-メール jiang28555@Gmail.com<br>
 **/
public class ResultModel<T> {

    public static final String SUCCESS_MSG="操作成功";

    /**
     *  处理状态
     */
    private int status=0;

    //返回状态,200正常
    private int code=200;


    private List statusParams;

    /**
     * 信息
     */
    private String msg=SUCCESS_MSG;

    /**
     * 数据信息
     */
    private T Data;


    public T getData() {
        return Data;
    }

    public void setData(T data) {
        Data = data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int errorgroup,int errorcode){
        this.status=(errorgroup << ResultException.GROUP_BIT)+errorcode;
    }

    public void setStatus(int status) {
        if(1==status){
            this.status = ((911 << ResultException.GROUP_BIT)+status);
        }else{
            this.status = status;
        }

    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    public ResultModel addStatusParams(Object... params){
        if(statusParams ==null){
            statusParams =new ArrayList();
        }
        if(params==null){
            return this;
        }
        for (Object param:params) {
            statusParams.add(param);
        }
        return this;
    }

    public List getStatusParams() {
        return statusParams;
    }

    public void setStatusParams(List statusParam) {
        this.statusParams = statusParam;
    }

    public ResultModel(int status) {
        this.status = status;
    }

    public ResultModel(int errorGroup,int status) {
        this.status=(errorGroup << ResultException.GROUP_BIT)+status;
    }

    public ResultModel() {
        super();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }
}
